package xpn.business.fund_return.entity.decision_stub;

import org.springframework.context.ApplicationContextException;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Objects;

@Service
public class DecisionStubService {
    @Resource
    private DecisionStubDao decisionStubDao;

    public DecisionStub save(DecisionStub decisionStub) {
        if (Objects.isNull(decisionStub.getId())) {
            DecisionStub exist = decisionStubDao.findAllByCaseId(decisionStub.getCaseId());
            if (Objects.nonNull(exist)) {
                throw new ApplicationContextException("该表单已存在，请勿重复创建");
            }
        }
        //提出公共字段保存至FrCase
        return decisionStubDao.save(decisionStub);
    }
}
